package com.example.ResponsibleChainPattern_Array;

import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * <pre>
 * 功能描述：
 * </pre>
 *
 * @author: 李明杰
 * @date: 2022/10/27 22:21
 */
@Component
public class FilterExecutionChain1 {

    //自动注入各个责任链的对象【@Order注解已经排序过了】
    @Resource
    private List<IFilter> iFilters;


    //直接调用这个方法使用
    public void exec(String request, String response) {
        for (IFilter iFilter : iFilters) {
            boolean isFinished = iFilter.doFilter(request, response);
            if (isFinished) {
                break;
            }
        }
    }


}

